﻿using WorkLogger.Client.DataAccess.Model;
using WorkLogger.Client.Forms;
using log4net;

namespace WorkLogger.Client.Services {
	public class StartDayCheckService {
		private readonly IWorkDayManager workDayManager;
		private static readonly ILog Log = LogManager.GetLogger(typeof(StartDayCheckService));

		public StartDayCheckService(IWorkDayManager workDayManager) {
			this.workDayManager = workDayManager;
		}

		public void Check() {
			WorkDay workDay = workDayManager.GetCurrentWorkDay();
			if (workDay.StartWorkingNotified == false) {
				Log.Info("Начало рабочего дня.");
				using (var form = new StartWorkingForm()) {
					form.StartWorking = workDay.StartWork;
					form.ShowDialog();
				}
				workDay.StartWorkingNotified = true;
				workDayManager.Update();
			}
		}
	}
}